package com.dq;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @ClassName Tomcat
 * @Description tomcat主要类
 * @Author DuX1aoQiang
 * @Date 2023/5/28 16:50
 * @Version 1.0
 */
public class Tomcat {

    public void start() {
        try {
            ExecutorService threadPool = Executors.newFixedThreadPool(20);
            ServerSocket serverSocket = new ServerSocket(8080);
            while (true) {
                Socket socket = serverSocket.accept();
                threadPool.execute(new SocketProcessor(socket));
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        }

    }

    public static void main(String[] args) {
        Tomcat tomcat = new Tomcat();
        tomcat.start();
    }
}
